package com.freemarker;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.view.freemarker.FreeMarkerView;

public class RichFreeMarkerView extends FreeMarkerView {
    
    public static final String CONTEXT_BASE = "base"; 

    @Override
    protected void exposeHelpers(Map<String, Object> model, HttpServletRequest request) throws Exception {
        super.exposeHelpers(model, request);
        StringBuffer base = new StringBuffer();
        base.append(request.getRequestURL());
        base.delete(base.lastIndexOf(request.getServletPath()), base.length());
        
        model.put(CONTEXT_BASE, base.toString()); 
    }

}
